package com.travelparadise.dao;

import java.util.Collection;

import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.travelparadise.domain.Client;

public class ClientDaoHibernate extends HibernateDaoSupport implements ClientDao {

	@Override
	public Client getById(int id) {
		HibernateTemplate hibernateTemplate = this.getHibernateTemplate();
		Client client = (Client) hibernateTemplate.get(com.travelparadise.domain.Client.class, id);
		return client;
	}

	public Collection<Client> getByEmail(String email) {
		String reqHQL = "select client from Client as client where client.getEmail like '"+email+"'";
		return this.getHibernateTemplate().find(reqHQL);
	}

	@Override
	public void createClient(Client client) {
		this.getHibernateTemplate().save(client);		
	}

	@Override
	public void updateClient(Client client) {
		this.getHibernateTemplate().update(client);
	}
}